package com.hzdp.web.ops.remote;

import java.util.ArrayList;
import java.util.List;

//import com.dianping.lion.client.ConfigCache;
//import com.dianping.lion.client.ConfigChange;

public class ProxyConfig {
	public static final String PROXY_KEY = "ops-remote-host.proxy";

	protected static final List<IpScope> PROXY_SCOPES = new ArrayList<IpScope>();

	static {
		loadLionConfig();
		try {
//			ConfigCache.getInstance().addChange(new ConfigChange() {
//				@Override
//				// 当lion的值发现变化时再触发一次
//				public void onChange(String key, String value) {
//					if (PROXY_KEY.equals(key)) {
//						loadLionConfig();
//					}
//				}
//			});
		} catch (Exception ex) {
		}
	}

	public static synchronized List<IpScope> getProxy() {
		return PROXY_SCOPES;
	}

	public static synchronized void loadLionConfig() {
		try {
//			String proxy = ConfigCache.getInstance().getProperty(PROXY_KEY);
//			String[] proxyLines = proxy.split("\n");
//			PROXY_SCOPES.clear();
//			for (String proxyString : proxyLines) {
//				IpScope scope = IpScope.getIpScope(proxyString.trim());
//				if (scope.startIp >= 0) {
//					PROXY_SCOPES.add(scope);
//				}
//			}
		} catch (Exception ex) {

		}
	}
}
